<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <base href="<%= basePath %>"/>
    <title>普通用户管理</title>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <script type="text/javascript" src="pages/js/pagination.js"></script>
    <style>
        /* 重置与基础布局 - 与供应商页面保持一致 */
        body {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            background-color: #f5f7fa;
        }
        .container {
            width: 90%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        h1 {
            margin-bottom: 20px;
            font-size: 24px;
            color: #333;
            border-left: 5px solid #008c8c;
            padding-left: 10px;
        }

        /* 按钮与表单排版 - 复用供应商页面样式 */
        a.add-btn {
            display: inline-block;
            text-decoration: none;
            padding: 8px 15px;
            background-color: #008c8c;
            color: #fff;
            border-radius: 4px;
            margin-right: 20px;
        }
        form {
            display: inline-block;
            vertical-align: middle;
        }
        form input[type="text"] {
            padding: 6px 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-right: 8px;
        }
        form input[type="submit"] {
            padding: 6px 15px;
            background-color: #409eff;
            color: #fff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        /* 表格样式 - 保持与供应商页面完全一致 */
        .table-wrapper {
            overflow-x: auto;
            margin-top: 20px;
        }
        table{
            width: 100%;
            border-collapse: collapse;
            min-width: 800px;
        }
        table caption{
            font-size: 2em;
            font-weight: bold;
            margin: 1em 0;
        }
        th,td{
            border: 1px solid #999;
            text-align: center;
            padding: 12px 8px;
            word-break: break-all;
        }
        table thead tr{
            background-color: #008c8c;
            color: #fff;
        }
        table tbody tr:nth-child(odd){
            background-color: #eee;
        }
        table tbody tr:hover{
            background-color: #ccc;
        }
        table tbody tr td:first-child{
            color: #f40;
        }
        table tfoot tr td{
            text-align: right;
            padding-right: 20px;
        }

        /* 操作按钮样式调整 */
        td a {
            margin: 0 5px;
            text-decoration: none;
            padding: 3px 8px;
            border-radius: 3px;
            font-size: 14px;
        }
        td a:first-child {
            color: #409eff;
            border: 1px solid #409eff;
        }
        td a:nth-child(2) {
            color: #f56c6c;
            border: 1px solid #f56c6c;
        }
        td a:nth-child(3) {
            color: #faad14;
            border: 1px solid #faad14;
        }
        td a:last-child {
            color: #52c41a;
            border: 1px solid #52c41a;
        }
        td a:hover {
            color: #fff;
        }
        td a:first-child:hover {
            background-color: #409eff;
        }
        td a:nth-child(2):hover {
            background-color: #f56c6c;
        }
        td a:nth-child(3):hover {
            background-color: #faad14;
        }
        td a:last-child:hover {
            background-color: #52c41a;
        }

        /* 分页按钮 - 与供应商页面保持一致 */
        body > a {
            display: inline-block;
            text-decoration: none;
            padding: 6px 12px;
            color: #409eff;
            border: 1px solid #409eff;
            border-radius: 4px;
            margin: 0 5px;
            margin-top: 15px;
        }
        body > a:hover {
            background-color: #409eff;
            color: #fff;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>合同管理</h1>
</div>
<form action="SupplyFileUpServlet" method="post" enctype="multipart/form-data">

    <label for="fileUp">上传文件：</label><%--合同名--%>
    <input type="file" id="fileUp" name="fileUp" required>

    <select name="supplier">
        <c:forEach items="${suppliers}" var="supplier">
            <option value="${supplier.id}">${supplier.name}</option>

        </c:forEach>

    </select>
    <input type="submit" value="添加"><%--按下此按钮开始进行添加（转到--待修改）--%>

</form>
</div>
<form method="post" action="ContractSServlet?method=select">
    合同名：<input type="text" name="contractname" value="${contractname}">
    合同ID：<input type="text" name="supplierid" value="${supplierid}">
    <input type="submit" value="查询">
</form>

<div class="table-wrapper">
    <table>
        <thead>
        <tr>
            <th>id</th>
            <th>合同名</th>
            <th>合同路径</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>创建时间</th>
            <th>更新时间</th>
            <th>删除状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${contracts}" var="contract">
            <tr>
                <td>${contract.id}</td>
                <td><a href="${pageContext.request.contextPath}${contract.documentpath}" target="_blank">
                        ${contract.contractname}</a>
                </td>

                <td>${contract.supplierid}</td>
                <td>${contract.startdate}</td>
                <td>${contract.enddate}</td>
                <td>${contract.createtime}</td>
                <td>${contract.updatetime}</td>
                <td>${contract.isdeleted}</td>
                <td>
                    <a href="ContractChangeServlet?method=updateBefore&id=${contract.id}">修改</a>
                    <a href="DeleteContractServlet?id=${contract.id}">删除</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<a href="ContractSServlet?page=${(page==1)?1:page-1}">上一页</a>&nbsp;
<a href="ContractSServlet?page=1">首页</a>&nbsp;
<a href="ContractSServlet?page=${page+1}">下一页</a>&nbsp;
</body>
</html>